/*
 * @(#)UserDAOImpl.java	2013-3-31 下午8:12:16
 * intranet
 * Copyright 2013 Thuisoft, Inc. All rights reserved.
 * THUNISOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.thunisoft.intranet.user.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.thunisoft.intranet.domain.TUser;
import com.thunisoft.intranet.user.dao.IUserDAO;

/**
 * UserDAOImpl
 * 
 * @author ice
 * @version 1.0
 * 
 */
public class UserDAOImpl implements IUserDAO {

    /**
     * 会话工厂
     */
    @Autowired
    private SessionFactory sessionFactory;

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.thunisoft.intranet.login.dao.IUserDAO#saveOrUpdate(com.thunisoft.
     * intranet.domain.TUser)
     */
    @Override
    public void saveOrUpdate(TUser user) {
        sessionFactory.getCurrentSession().saveOrUpdate(user);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.thunisoft.intranet.user.dao.IUserDAO#getAllUserList()
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<TUser> getAllUserList() {
        StringBuilder sbHql = new StringBuilder();
        sbHql.append("SELECT    ");
        sbHql.append("  *   ");
        sbHql.append("FROM  ");
        sbHql.append("  TUser   ");
        Query query = sessionFactory.getCurrentSession().createQuery(
                sbHql.toString());
        List<TUser> list = query.list();
        return list;
    }

}
